<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>

<body>
	<script>
		let str = 'dfedfsedfsedf '
		function count(str) {
			let arr = str.split(' ')
			let _arr = []
			for (let i = 0; i < arr.length; i++) {
				const ele = arr[i];
				_arr = _arr.concat(ele.split(''))
			}
			let setArr = [...new Set(_arr)]
			let obj = {}
			setArr.forEach((v, i) => {
				obj[v] = 0
				let num = 0
				for (let index = 0; index < _arr.length; index++) {
					const ele = _arr[index];
					console.log(ele, v, index);
					if (ele == v) {
						++num
						obj[v] = num
					}

				}
			})
			return obj

		}
		console.log(count(str));

	</script>
</body>

</html>